#ifndef QTSTRA2_H
#define QTSTRA2_H


#include <QTabWidget>
#include "QtInstrument.h"
#include "QtStra_Xml.h"
#include "QtStra_Thread.h"

class QDockWidget;
class QSplitter;
class QTableWidget;
class QPushButton;
class QTabWidget;


class QtStra2 : public QTabWidget
{
	Q_OBJECT

public:
	QtStra2(QDockWidget* instDock, QDockWidget* strategyDock, QTabWidget::TabPosition pos = QTabWidget::South, QWidget *parent = 0);

	void CreateThread();

	void DestroyThread();

	void OnUpdateInstDockAndStrategyDock();

	void OnDestroyAllBars();

	void OnReinitAllBars();

	void OnTimer(TimerFire_namespace::TimerFireType timertype);

	

private:

	void CreateStrategyInfo(QDockWidget* strategyDock);

	void CreateInstInfo(QDockWidget* instDock);

	void ReadXml();

	void WriteXml();

	void SetVbarrltnew();


	void Edit_Del_AddInst(TimerFire_namespace::TimerFireType timertype);
	bool AddInst(TimerFire_namespace::TimerFireType timertype, vector<MFCData*>& vpmfcdata);
	bool DelInst(TimerFire_namespace::TimerFireType timertype, vector<MFCData*>& vpmfcdata);
	bool EditInst(TimerFire_namespace::TimerFireType timertype, vector<MFCData*>& vpmfcdata);


	void StartCtl(TimerFire_namespace::TimerFireType timertype = TimerFire_namespace::invalid);

	
private slots:

	void OnctlBtnClicked();

	void OneditBtnClicked();

	void OnreadxmlBtnClicked();

	void OnwritexmlBtnClicked();

	void OnSlotInit(BarSeries* pBarSer, BarData* pData);

	void OnSlotDestroy(BarInfo* pbar);

	void OnSlotSysMd(BarData* pData);

private:

	//m_instDock and elements in it
	QDockWidget* m_instDock;
	QSplitter* m_instSplitter;
	QTableWidget *m_instTable;
	QPushButton *m_ctlBtn;
	QPushButton *m_editBtn;
	QPushButton *m_readXmlBtn;
	QPushButton *m_writeXmlBtn;


	//m_strategyDock  and elements in it
	QDockWidget* m_strategyDock;
	QtStraStrategyInfo* m_strategyinfo;

	string m_xmlfile;

	QtStraXml* m_xml;
	
	QtStraThread* m_thread;


	//map<string, int> m_mapInstTab;


//above part could be wrote into a parent class then inhert, 
//below couldn't be inert
private:

	typedef struct Stra2Related
	{
		BarInfo bar;

		userdata_stra2 userdata;
	}Stra2Related;

	vector<Stra2Related> m_stra2thd1_vbarrltold;
	vector<Stra2Related> m_stra2thd1_vbarrltnew;


};



#endif
